import 'package:flutter/material.dart';
import 'package:flutter_1800/pages/widgets/MyNetImage.dart';
import 'package:flutter_1800/tools/config.dart';

class Avatar extends StatelessWidget {
  String? url;

  Avatar(this.url, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    if (url != null && url!.isNotEmpty && !url!.startsWith("http")) {
      return MyNetImage(
        url: AppConfig.DOMAIN + url!,
      );
    }
    return url == null || url!.isEmpty
        ? Image.asset(
            "images/mall/avatar.jpg",
            fit: BoxFit.cover,
          )
        : MyNetImage(
            url: url!,
            fit: BoxFit.cover,
          );
  }
}
